<template>
  <div class="TableDetail">
    <!-- 客户列表 -->
    <div v-if="$route.params.state" class="KHLB">
      <h4>客户列表</h4>
      <el-table
        v-loading="loading"
        :data="Bindata"
        class="cus-table"
        :header-cell-style="handleCellStyle"
      >
        <el-table-column label="用户" prop="nickName" />
        <el-table-column label="手机号码" prop="mobile" />
        <el-table-column label="订单数" prop="orderCount" />
        <el-table-column label="消费金额" prop="orderPriceCount" />
        <el-table-column label="贡献佣金" prop="proxyPriceCount" />
      </el-table>
    </div>
    <!-- 提现记录 -->
    <div v-else class="TXJL">
      <h4>提现记录</h4>
      <el-table
        v-loading="loading"
        :data="Bindata"
        class="cus-table"
        :header-cell-style="handleCellStyle"
      >
        <el-table-column label="提现编号" prop="withdrawalNumber" />
        <el-table-column label="提现金额" prop="money" />
        <el-table-column label="提现时间" prop="addTime" />
      </el-table>
    </div>
  </div>
</template>

<script>
import {
  ExtensionPromoterLJKH,
  ExtensionPromoterTXJL
} from '@/api/customAPI/shop/ExtensionManagement'
export default {
  name: 'TableDetail',
  data() {
    return {
      loading: false,
      Bindata: []
    }
  },
  created() {
    this.Init()
  },
  methods: {
    Init() {
      this.loading = true
      if (this.$route.params.state === true) {
        ExtensionPromoterLJKH({ promoterId: this.$route.params.id })
          .then(result => {
            this.Bindata = result.data.data
            this.loading = false
          })
          .catch(err => {
            console.log(err)
          })
      } else if (this.$route.params.state === false) {
        ExtensionPromoterTXJL({ promoterId: this.$route.params.id })
          .then(result => {
            this.Bindata = result.data.data
            this.loading = false
          })
          .catch(err => {
            console.log(err)
          })
      } else {
        this.$router.replace({ name: 'ExtensionDetail' })
      }
    },
    handleCellStyle({ row, column, rowIndex, columnIndex }) {
      if (rowIndex === 0) {
        return 'background:#f3f3f3'
      } else {
        return ''
      }
    }
  }
}
</script>

<style lang="scss" scoped>
.TableDetail {
  padding: 50px 100px;
}
</style>
